//
//  ZZRegisterViewController.m
//  ZuZuBao
//
//  Created by Felix on 2024/4/8.
//

#import "ZZRegisterViewController.h"

@interface ZZRegisterViewController ()

@property (nonatomic, strong) UITextField * pTxField;
@property (nonatomic, strong) UITextField * cTxField;
@property (nonatomic, strong) UITextField * rTxField;


@end

@implementation ZZRegisterViewController

-(void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
//    [self.navigationController setNavigationBarHidden:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"";
    
    [self createView];
    
}

- (void)createView {
    UIImageView * bkImgVIew = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
    bkImgVIew.image = [UIImage imageNamed:@"back_image"];
    [self.view addSubview:bkImgVIew];
    
    UIImageView * imgView = [[UIImageView alloc] initWithFrame:CGRectMake(53, kNavBarHeight, kScreenWidth - 53 * 2, 196)];
    imgView.contentMode = UIViewContentModeScaleAspectFit;
    imgView.image = [UIImage imageNamed:@"login_img"];
    [self.view addSubview:imgView];
    
    self.pTxField = [[UITextField alloc] initWithFrame:CGRectMake(kPadding, CGRectGetMaxY(imgView.frame) + 20, kScreenWidth - kPadding * 2, 48)];
    self.pTxField.backgroundColor = kRGBAColor(0xD9E4F3, 1);
    self.pTxField.layer.cornerRadius = 24;
    self.pTxField.layer.masksToBounds = YES;
    self.pTxField.placeholder = @"请输入手机号";
    self.pTxField.textColor = k333Color;
    self.pTxField.font = [UIFont systemFontOfSize:16];
    self.pTxField.leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kPadding, 48)];
    self.pTxField.leftViewMode = UITextFieldViewModeAlways;
    [self.view addSubview:self.pTxField];
    
    self.cTxField = [[UITextField alloc] initWithFrame:CGRectMake(kPadding, CGRectGetMaxY(self.pTxField.frame) + 25, kScreenWidth - kPadding * 2, 48)];
    self.cTxField.backgroundColor = kRGBAColor(0xD9E4F3, 1);
    self.cTxField.layer.cornerRadius = 24;
    self.cTxField.layer.masksToBounds = YES;
    self.cTxField.placeholder = @"请输入密码";
    self.cTxField.textColor = k333Color;
    self.cTxField.font = [UIFont systemFontOfSize:16];
    self.cTxField.leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kPadding, 48)];
    self.cTxField.leftViewMode = UITextFieldViewModeAlways;
    [self.view addSubview:self.cTxField];
    
    self.rTxField = [[UITextField alloc] initWithFrame:CGRectMake(kPadding, CGRectGetMaxY(self.cTxField.frame) + 25, kScreenWidth - kPadding * 2, 48)];
    self.rTxField.backgroundColor = kRGBAColor(0xD9E4F3, 1);
    self.rTxField.layer.cornerRadius = 24;
    self.rTxField.layer.masksToBounds = YES;
    self.rTxField.placeholder = @"请再次输入密码";
    self.rTxField.textColor = k333Color;
    self.rTxField.font = [UIFont systemFontOfSize:16];
    self.rTxField.leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kPadding, 48)];
    self.rTxField.leftViewMode = UITextFieldViewModeAlways;
    [self.view addSubview:self.rTxField];
    
    UIButton * registerButton = [UIButton buttonWithType:UIButtonTypeCustom];
    registerButton.frame = CGRectMake(kPadding, CGRectGetMaxY(self.rTxField.frame) + 25, kScreenWidth - kPadding * 2, 48);
    registerButton.backgroundColor = [UIColor blackColor];
    registerButton.layer.cornerRadius = 24;
    registerButton.layer.masksToBounds = YES;
    [registerButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [registerButton setTitle:@"注册" forState:UIControlStateNormal];
    registerButton.titleLabel.font = [UIFont boldSystemFontOfSize:18];
    [registerButton addTarget:self action:@selector(registerAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:registerButton];
    
    UIButton * loginButton = [UIButton buttonWithType:UIButtonTypeCustom];
    loginButton.frame = CGRectMake(kPadding, CGRectGetMaxY(registerButton.frame) + 10, kScreenWidth - kPadding * 2, 34);
    NSString *string = @"已有账号，去登录";
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:string];
    NSRange helloRange = [string rangeOfString:@"已有账号，去"];
    [attributedString addAttribute:NSForegroundColorAttributeName
                               value:k333Color
                               range:helloRange];
    NSRange worldRange = [string rangeOfString:@"登录"];
    [attributedString addAttribute:NSForegroundColorAttributeName
                               value:kRGBAColor(0x127FFF, 1)
                               range:worldRange];
    [loginButton setAttributedTitle:attributedString forState:UIControlStateNormal];
    loginButton.titleLabel.font = [UIFont systemFontOfSize:14];
    [loginButton addTarget:self action:@selector(loginAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:loginButton];
    
    

}

- (void)loginAction {
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)registerAction {
    
    [self.navigationController popViewControllerAnimated:YES];
}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    [self.view endEditing:YES];
}

@end
